#include <iostream>
#include <stack>
#include <string>
bool isValidSequence(const std::string& input) {
    std::stack<char> stack;
    const std::string opening = "({[<";
    const std::string closing = ")}]>";

    for (char c : input) {
        if (opening.find(c) != std::string::npos) {
            stack.push(c);
        } else if (closing.find(c) != std::string::npos) {
            if (stack.empty() || opening.find(stack.top()) != closing.find(c)) {
                return false;
            }
            stack.pop();
        }
    }
    return stack.empty();
}
int main() {
    std::string input;
    std::cin >> input;
    std::cout << std::boolalpha << isValidSequence(input) << std::endl;
    return 0;
}